# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: manager ticketclerk tickettaker concessionclerk movietechnician headcustomer regularcustomer createcc1 createcc2 createcc3 createtccc createmtttmm inittheater rpctest1 rpctest2 rpctest3 rpctest4 rpctest5 extra extra1 testcv testcv1 testcv2 rpctests1 rpctests2 rpctests3 rpctestse1 testlock testlock1 createinit

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s
	
manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c 
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff 
	../bin/coff2noff manager.coff manager

ticketclerk.o: ticketclerk.c
	$(CC) $(CFLAGS) -c ticketclerk.c 
ticketclerk: ticketclerk.o start.o
	$(LD) $(LDFLAGS) start.o ticketclerk.o -o ticketclerk.coff 
	../bin/coff2noff ticketclerk.coff ticketclerk
	
tickettaker.o: tickettaker.c
	$(CC) $(CFLAGS) -c tickettaker.c 
tickettaker: tickettaker.o start.o
	$(LD) $(LDFLAGS) start.o tickettaker.o -o tickettaker.coff 
	../bin/coff2noff tickettaker.coff tickettaker

concessionclerk.o: concessionclerk.c
	$(CC) $(CFLAGS) -c concessionclerk.c 
concessionclerk: concessionclerk.o start.o
	$(LD) $(LDFLAGS) start.o concessionclerk.o -o concessionclerk.coff 
	../bin/coff2noff concessionclerk.coff concessionclerk

movietechnician.o: movietechnician.c
	$(CC) $(CFLAGS) -c movietechnician.c 
movietechnician: movietechnician.o start.o
	$(LD) $(LDFLAGS) start.o movietechnician.o -o movietechnician.coff 
	../bin/coff2noff movietechnician.coff movietechnician

headcustomer.o: headcustomer.c
	$(CC) $(CFLAGS) -c headcustomer.c 
headcustomer: headcustomer.o start.o
	$(LD) $(LDFLAGS) start.o headcustomer.o -o headcustomer.coff 
	../bin/coff2noff headcustomer.coff headcustomer

regularcustomer.o: regularcustomer.c
	$(CC) $(CFLAGS) -c regularcustomer.c 
regularcustomer: regularcustomer.o start.o
	$(LD) $(LDFLAGS) start.o regularcustomer.o -o regularcustomer.coff 
	../bin/coff2noff regularcustomer.coff regularcustomer
	
createcc1.o: createcc1.c
	$(CC) $(CFLAGS) -c createcc1.c 
createcc1: createcc1.o start.o
	$(LD) $(LDFLAGS) start.o createcc1.o -o createcc1.coff 
	../bin/coff2noff createcc1.coff createcc1
	
createcc2.o: createcc2.c
	$(CC) $(CFLAGS) -c createcc2.c 
createcc2: createcc2.o start.o
	$(LD) $(LDFLAGS) start.o createcc2.o -o createcc2.coff 
	../bin/coff2noff createcc2.coff createcc2	
	
createcc3.o: createcc3.c
	$(CC) $(CFLAGS) -c createcc3.c 
createcc3: createcc3.o start.o
	$(LD) $(LDFLAGS) start.o createcc3.o -o createcc3.coff 
	../bin/coff2noff createcc3.coff createcc3

createtccc.o: createtccc.c
	$(CC) $(CFLAGS) -c createtccc.c 
createtccc: createtccc.o start.o
	$(LD) $(LDFLAGS) start.o createtccc.o -o createtccc.coff 
	../bin/coff2noff createtccc.coff createtccc

createmtttmm.o: createmtttmm.c
	$(CC) $(CFLAGS) -c createmtttmm.c 
createmtttmm: createmtttmm.o start.o
	$(LD) $(LDFLAGS) start.o createmtttmm.o -o createmtttmm.coff 
	../bin/coff2noff createmtttmm.coff createmtttmm
	
inittheater.o: inittheater.c
	$(CC) $(CFLAGS) -c inittheater.c 
inittheater: inittheater.o start.o
	$(LD) $(LDFLAGS) start.o inittheater.o -o inittheater.coff 
	../bin/coff2noff inittheater.coff inittheater
	
rpctest1.o: rpctest1.c
	$(CC) $(CFLAGS) -c rpctest1.c 
rpctest1: rpctest1.o start.o
	$(LD) $(LDFLAGS) start.o rpctest1.o -o rpctest1.coff 
	../bin/coff2noff rpctest1.coff rpctest1
	
rpctest2.o: rpctest2.c
	$(CC) $(CFLAGS) -c rpctest2.c 
rpctest2: rpctest2.o start.o
	$(LD) $(LDFLAGS) start.o rpctest2.o -o rpctest2.coff 
	../bin/coff2noff rpctest2.coff rpctest2

rpctest3.o: rpctest3.c
	$(CC) $(CFLAGS) -c rpctest3.c 
rpctest3: rpctest3.o start.o
	$(LD) $(LDFLAGS) start.o rpctest3.o -o rpctest3.coff 
	../bin/coff2noff rpctest3.coff rpctest3

rpctest4.o: rpctest4.c
	$(CC) $(CFLAGS) -c rpctest4.c 
rpctest4: rpctest4.o start.o
	$(LD) $(LDFLAGS) start.o rpctest4.o -o rpctest4.coff 
	../bin/coff2noff rpctest4.coff rpctest4

rpctest5.o: rpctest5.c
	$(CC) $(CFLAGS) -c rpctest5.c 
rpctest5: rpctest5.o start.o
	$(LD) $(LDFLAGS) start.o rpctest5.o -o rpctest5.coff 
	../bin/coff2noff rpctest5.coff rpctest5
	
extra.o: extra.c
	$(CC) $(CFLAGS) -c extra.c
extra: extra.o start.o
	$(LD) $(LDFLAGS) start.o extra.o -o extra.coff
	../bin/coff2noff extra.coff extra
	
extra1.o: extra1.c
	$(CC) $(CFLAGS) -c extra1.c 
extra1: extra1.o start.o
	$(LD) $(LDFLAGS) start.o extra1.o -o extra1.coff 
	../bin/coff2noff extra1.coff extra1

testcv.o: testcv.c
	$(CC) $(CFLAGS) -c testcv.c
testcv: testcv.o start.o
	$(LD) $(LDFLAGS) start.o testcv.o -o testcv.coff
	../bin/coff2noff testcv.coff testcv

testcv1.o: testcv1.c
	$(CC) $(CFLAGS) -c testcv1.c
testcv1: testcv1.o start.o
	$(LD) $(LDFLAGS) start.o testcv1.o -o testcv1.coff
	../bin/coff2noff testcv1.coff testcv1

testcv2.o: testcv2.c
	$(CC) $(CFLAGS) -c testcv2.c
testcv2: testcv2.o start.o
	$(LD) $(LDFLAGS) start.o testcv2.o -o testcv2.coff
	../bin/coff2noff testcv2.coff testcv2

rpctests1.o: rpctests1.c
	$(CC) $(CFLAGS) -c rpctests1.c 
rpctests1: rpctests1.o start.o
	$(LD) $(LDFLAGS) start.o rpctests1.o -o rpctests1.coff 
	../bin/coff2noff rpctests1.coff rpctests1

rpctests2.o: rpctests2.c
	$(CC) $(CFLAGS) -c rpctests2.c 
rpctests2: rpctests2.o start.o
	$(LD) $(LDFLAGS) start.o rpctests2.o -o rpctests2.coff 
	../bin/coff2noff rpctests2.coff rpctests2


rpctests3.o: rpctests3.c
	$(CC) $(CFLAGS) -c rpctests3.c 
rpctests3: rpctests3.o start.o
	$(LD) $(LDFLAGS) start.o rpctests3.o -o rpctests3.coff 
	../bin/coff2noff rpctests3.coff rpctests3

rpctestse1.o: rpctestse1.c
	$(CC) $(CFLAGS) -c rpctestse1.c 
rpctestse1: rpctestse1.o start.o
	$(LD) $(LDFLAGS) start.o rpctestse1.o -o rpctestse1.coff 
	../bin/coff2noff rpctestse1.coff rpctestse1

testlock.o: testlock.c
	$(CC) $(CFLAGS) -c testlock.c
testlock: testlock.o start.o
	$(LD) $(LDFLAGS) start.o testlock.o -o testlock.coff
	../bin/coff2noff testlock.coff testlock
	
testlock1.o: testlock1.c
	$(CC) $(CFLAGS) -c testlock1.c 
testlock1: testlock1.o start.o
	$(LD) $(LDFLAGS) start.o testlock1.o -o testlock1.coff 
	../bin/coff2noff testlock1.coff testlock1

createinit.o: createinit.c
	$(CC) $(CFLAGS) -c createinit.c 
createinit: createinit.o start.o
	$(LD) $(LDFLAGS) start.o createinit.o -o createinit.coff 
	../bin/coff2noff createinit.coff createinit

clean:
	rm -f *.o *.coff
